#ifndef __TETRIS_PIECE_H__
#define __TETRIS_PIECE_H__

#include "OgreSceneNode.h"
#include "OgreMemoryAllocatorConfig.h"

class cTetrisPiece;
class Ogre::SceneManager;

enum eTetrisPiece
{
	PIECE_NONE = -1,
	PIECE_I,
	PIECE_T,
	PIECE_SQUARE,						
	PIECE_L,		
	PIECE_N,
	PIECE_L_MIRR,		
	PIECE_N_MIRR,					
	PIECE_TOTAL,
};

class cTetrisPiece : public Ogre::UtilityAlloc
{
public:
		cTetrisPiece(Ogre::SceneManager* pScene, eTetrisPiece type, float fRot);	
		~cTetrisPiece(); 

	inline	void					 SetPosition(const Ogre::Vector3& pos);
	inline	const	Ogre::Vector3&	 GetPosition();
	inline	const	Ogre::Vector3&	 GetInitialPos();
	inline			Ogre::SceneNode* GetParentNode();
			void	Update(float fDeltaTime, const Ogre::Vector3& vDir, float speed, const Ogre::Vector3& vOffset);
private:
		Ogre::SceneNode*	m_pParentNode;
		Ogre::Vector3		m_vParentPos;
		Ogre::Vector3		m_vInitialPos;
		char				m_szPieceId[64];	
		static int			m_nPieceId;

					void	MakePiece(Ogre::SceneManager* pScene = NULL, eTetrisPiece type = PIECE_NONE, float fRot = 0.f);
		const Ogre::String	GetRandomMesh();
		const Ogre::String	GetMesh(int idx);

		cTetrisPiece(const cTetrisPiece& other);
		cTetrisPiece& operator=(const cTetrisPiece& other);		
};

void cTetrisPiece::SetPosition(const Ogre::Vector3& pos)
{
	if (m_pParentNode)
		m_pParentNode->setPosition(pos);
	m_vParentPos = pos;
}

const Ogre::Vector3& cTetrisPiece::GetPosition()
{	
	return m_vParentPos;
}

const Ogre::Vector3& cTetrisPiece::GetInitialPos()
{
	return m_vInitialPos;
}

Ogre::SceneNode* cTetrisPiece::GetParentNode()
{
	return m_pParentNode;
}

#endif // __TETRIS_PIECE_H__